remove duplicates in Array

Filter out any duplicates and return a single array of unique categories in Javascript

const array = ['apple', 'apple', 'orange', 'pear', 'banana']
const uniq = [...new Set(array)];

( Note that var uniq will be an array... new Set() turns it into a set, but [...] turns it back into an array again )


Credits